# 名称:Backdream
# 时间2022/12/27  10:12
# 活动页面类

from appium.webdriver.common.mobileby import MobileBy as By
from pages.base_page import BasePage


class ActivityPage(BasePage):
    '''定位器'''
    # 点击评论按钮进入评论
    comment_locator = (By.XPATH, "//android.widget.TextView[@resource-id=\"com.gfeng.daydaycook:id/tv_comment\"]")

    def comment_click(self):
        self.driver.find_element(*self.comment_locator).click()

    # 评论框
    comment_send_locator = (
        By.XPATH, "//android.widget.EditText[@resource-id=\"com.gfeng.daydaycook:id/et_comment\"]")


    def comment_text_send(self, text):
        self.driver.find_element(*self.comment_send_locator).send_keys(text)

    #发送按钮
    send_btn_locator=(By.XPATH,"//android.widget.TextView[@resource-id=\"com.gfeng.daydaycook:id/tv_commit\"]")
    def send_btn(self):
        self.driver.find_element(*self.send_btn_locator).click()

    # 断言评论

    def comment_assert(self, text):
        self.comment_assert_locator = (By.XPATH, "//android.widget.TextView[@text=\"{}\"]".format(text))
        # xx = (self.comment_assert_locator[0],self.comment_assert_locator[1].format(text))
        return self.driver.find_element(*self.comment_assert_locator).text

    # 断言下滑20次页面菜谱
    food_name_locator=(By.XPATH,"//android.widget.TextView[@text=\"超好吃的减脂餐，坚果酸奶紫薯泥！\"]")
    def food_name(self):
        return self.driver.find_element(*self.food_name_locator).text

    #向下滑动20次
    def swipe_up_20(self):
        basepage=BasePage(self.driver)
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()
        basepage.swipe_up()

